from scipy import stats
import numpy as np

# 标准正态分布 (均值=0, 标准差=1)
dist = stats.norm(loc=0, scale=1)

# (a) 计算 $W_1$ 大于1的概率，即 $P(W_1 > 1)$. 
p1 = 1-dist.cdf(1)
print(f'P(W_1 > 1) = {p1:.4f}')

# (b) 已知在时间 $t=2$ 时，$W_2 = 1.5$，求条件概率 $P(W_3 > 2 \mid W_2 = 1.5)$. 
p2 = 1-dist.cdf(0.5)
print(f'P(W_3 > 2 \mid W_2 = 1.5) = {p2:.4f}')

# (c) 设 $X_t = W_t + \mu t$ 为带漂移的布朗运动。若 $\mu = 0.3$，计算 $X_4$ 的分布，并求 $P(X_4 > 2)$. 
p3 = 1-dist.cdf(0.4)
print(f'P(X_4 > 2) = {p3:.4f}')

